package com.jmeurope.action;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import org.apache.struts2.json.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;

import com.jmeurope.model.News;
import com.jmeurope.service.NewsService;
import com.opensymphony.xwork2.ActionSupport;
/**
 * 
 * <p>
 * Description: 
 * </p>
 *
 * @author shanming
 * @version 1.0

 * <p>
 * History: 
 *
 * Date                     Author         Version     Description
 * ---------------------------------------------------------------------------------
 * 2012-1-2 下午4:36:26          wangwei        1.0         To create
 * </p>
 *
 * @since 
 * @see
 */
public class JMNewsAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//这里添加前台需要的各种方法
	private List<News> rows;
	@Autowired
	private NewsService newsService;
	private News news;
	//
	public String addNew(){
		news=new News();
		news.setAddDate(new Timestamp(new Date().getTime()));
		news.setBussinessModel(null);
		news.setContent(null);
		news.setDescr(null);
		news.setIsEn(null);
		news.setIsInnerNews(null);
		news.setStatus(null);
		news.setTitle(null);
		news.setUser(null);
		news.setUpdateDate(new Timestamp(new Date().getTime()));
		try {
			this.newsService.addNews(news);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SUCCESS;
	}
	@JSON(serialize=false)
	public String getAllNews(){
		try {
			rows=newsService.getAllNews();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return SUCCESS;
	}
	public News getNews() {
		return news;
	}
	public void setNews(News news) {
		this.news = news;
	}
	public List<News> getRows() {
		return rows;
	}
}
